import useGlobalAPI from '@/hooks/useGlobalAPI'
import {
  getRoleAuthData,
  ViewContentLeft,
  ViewContentRight,
  conf_roleOfApi_state
} from './components'

export default defineComponent({
  name: 'conf-roleOfApi',
  setup() {
    let { route } = useGlobalAPI()
    let { roleCode, roleName } = toRefs(conf_roleOfApi_state.currentRole)
    onMounted(async () => {
      if (Object.keys(route.query).length > 0) {
        roleCode.value = route.query.roleCode as string
        roleName.value = route.query.roleName as string
        getRoleAuthData()
      }
    })
    onUnmounted(() => {
      roleCode.value = null
      roleName.value = null
      console.log('onUnmounted')
    })
    return () => (
      <div class='h-full bg-default grid grid-cols-2 overflow-y-auto'>
        <ViewContentLeft></ViewContentLeft>
        <ViewContentRight></ViewContentRight>
      </div>
    )
  }
})
